﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Extensions;
using DevTeam;
using OTS.Utility;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;

namespace OTS
{
    public partial class Bakiyeler : XForm
    {
        public Bakiyeler()
        {
            InitializeComponent();
        }

        private void Bakiyeler_Load(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            gv.Init("GetCariBilgi", true, "", "");
            gv.FormatAsNumber(2, "TL", "USD", "EUR", "CHF");
            gv.MakeReadOnly();
            gv.BestFitColumns();
            gv.ColumnFilterChanged += gv_ColumnFilterChanged;
            this.Cursor = Cursors.Default;
        }

        void gv_ColumnFilterChanged(object sender, EventArgs e)
        {
            gv.BestFitColumns();
        }

        private void gc_DoubleClick(object sender, EventArgs e)
        {
            Point pt = gv.GridControl.PointToClient(Control.MousePosition);
            GridHitInfo info = gv.CalcHitInfo(pt.X, pt.Y);
            if (info.InDataRow)
            {
                if (!new string[] { "TL", "EUR", "USD", "CHF" }.Contains(info.Column.FieldName))
                {
                    MessageBox.Show("Lütfen detayını görmek istediğiniz para biriminin üzerinde çift tıklayın.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                DataRow dr = gv.GetDataRow(info.RowHandle);
                if (Math.Abs(dr[info.Column.FieldName].ToIntZero()) > 0)
                    AppSession.MainForm.ShowMdiChildForm(typeof(BakiyeDetaylari), dr["FirmaKodu"], dr["Firma"], info.Column.FieldName);
            }
        }
    }
}
